//
//  YWSelectInspectionLineCell.m
//  maintain
//
//  Created by Kyo on 16/9/6.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWSelectInspectionLineCell.h"
#import "YWMacro.h"
#import "Masonry.h"
#import "YWInspectionMissionModel.h"
#import "YWKeepWatchMission.h"

@interface YWSelectInspectionLineCell ()
@property (nonatomic, strong) UILabel *lineLabel;
@end
@implementation YWSelectInspectionLineCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"YWSelectInspectionLineCellIdentifier";
    YWSelectInspectionLineCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[YWSelectInspectionLineCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UILabel *label = [[UILabel alloc] init];
        label.font = kContentFont;
        [label addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickLabelEvent:)]];
        label.userInteractionEnabled = YES;
        _lineLabel = label;
        [self.contentView addSubview:label];
        [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).offset(10);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-30);
            make.top.and.bottom.mas_equalTo(self.contentView).offset(0);
        }];
    }
    return self;
}
- (void)setLineOption:(id)lineOption{
    _lineOption = lineOption;
    NSString *lineName = @"";
    if ([lineOption isKindOfClass:[YWInspectionLineOption class]]) {
        YWInspectionLineOption *option = (YWInspectionLineOption*)lineOption;
        lineName = option.inspectionLineName?:@"";
    }else if ([lineOption isKindOfClass:[YWPatrolLineOption class]]){
        YWPatrolLineOption *option = (YWPatrolLineOption*)lineOption;
        lineName = option.patrolLineName?:@"";
    }
    self.lineLabel.text = lineName;
}


- (void)clickLabelEvent:(id)sender{
    if ([self.delegate respondsToSelector:@selector(clickInspectionLineButton:)]) {
        [self.delegate clickInspectionLineButton:self];
    }
}
@end
